using System.Configuration;
using System.Data.Common;
using System.Data.SQLite;

using Microsoft.Practices.EnterpriseLibrary.Data;

using EntLibContrib.Data.SQLite;
using Microsoft.VisualStudio.TestTools.UnitTesting;


namespace EntLibContrib.Data.SQLite.Tests
{
    [TestClass]
    
    public class SQLiteDatabaseFixture
    {
        [TestMethod, DeploymentItem("EntLibContrib.Data.SqLite.Tests.dll.config"), DeploymentItem("Northwind.db")]
        public void ConnectionTest()
        {
            DatabaseConfigurationView view = new DatabaseConfigurationView(TestConfigurationSource.CreateConfigurationSource());
            ConnectionStringSettings data = view.GetConnectionStringSettings("SQLiteNorthwind");
            SQLiteDatabase sqliteDatabase = new SQLiteDatabase(data.ConnectionString);

            DbConnection connection = sqliteDatabase.CreateConnection();
            Assert.IsNotNull(connection);
            Assert.IsTrue(connection is SQLiteConnection);
            connection.Open();
            DbCommand cmd = sqliteDatabase.GetSqlStringCommand("Select * from Region");
            cmd.CommandTimeout = 60;
            Assert.AreEqual(cmd.CommandTimeout, 60);
        }
    } 
}